/*
 * Copyright (c) 2024 Black Sesame Technologies
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#include <gtest/gtest.h>
#include "dal_fastdds/converter/QosConverter.hpp"

TEST(participant_qos_convert_default, test_convert_qos)
{
    dal_ret_t ret;
    DomainParticipantQos f_qos;
    ret = QosConverter::GetInstance()->ConvertParticipantQosFromDalToFastdds(
        DAL_PARTICIPANT_QOS_DEFAULT, &f_qos);
    EXPECT_EQ(ret, DAL_RETCODE_OK);
    EXPECT_EQ(f_qos, PARTICIPANT_QOS_DEFAULT);
}

TEST(publisher_qos_convert_default, test_convert_qos)
{
    dal_ret_t ret;
    PublisherQos f_qos;

    ret = QosConverter::GetInstance()->ConvertPublisherQosFromDalToFastdds(
        DAL_PUBLISHER_QOS_DEFAULT, &f_qos);
    EXPECT_EQ(ret, DAL_RETCODE_OK);
    EXPECT_EQ(f_qos, PUBLISHER_QOS_DEFAULT);
}

TEST(subscriber_qos_convert_default, test_convert_qos)
{
    dal_ret_t ret;
    SubscriberQos f_qos;

    ret = QosConverter::GetInstance()->ConvertSubscriberQosFromDalToFastdds(
        DAL_SUBSCRIBER_QOS_DEFAULT, &f_qos);
    EXPECT_EQ(ret, DAL_RETCODE_OK);
    EXPECT_EQ(f_qos, SUBSCRIBER_QOS_DEFAULT);
}

TEST(topic_qos_convert_default, test_convert_qos)
{
    dal_ret_t ret;
    TopicQos f_qos;

    ret =
        QosConverter::GetInstance()->ConvertTopicQosFromDalToFastdds(DAL_TOPIC_QOS_DEFAULT, &f_qos);
    EXPECT_EQ(ret, DAL_RETCODE_OK);
    EXPECT_EQ(f_qos, TOPIC_QOS_DEFAULT);
}

TEST(datawriter_qos_convert_default, test_convert_qos)
{
    dal_ret_t ret;
    DataWriterQos f_qos;

    ret = QosConverter::GetInstance()->ConvertDataWriterQosFromDalToFastdds(
        DAL_DATAWRITER_QOS_DEFAULT, &f_qos);
    EXPECT_EQ(ret, DAL_RETCODE_OK);
    EXPECT_EQ(f_qos, DATAWRITER_QOS_DEFAULT);
}

TEST(datareader_qos_convert_default, test_convert_qos)
{
    dal_ret_t ret;
    DataReaderQos f_qos;

    ret = QosConverter::GetInstance()->ConvertDataReaderQosFromDalToFastdds(
        DAL_DATAREADER_QOS_DEFAULT, &f_qos);
    EXPECT_EQ(ret, DAL_RETCODE_OK);
    EXPECT_EQ(f_qos, DATAREADER_QOS_DEFAULT);
}

TEST(participant_qos_convert_with_locator, test_convert_qos)
{
    dal_ret_t ret;
    dal_domain_participant_qos_t d_qos = { };
    DomainParticipantQos f_qos;
    const char* multicast_ip_1 = "239.123.121.1";
    const char* multicast_ip_2 = "239.111.222.2";
    const char* unicast_ip_1 = "192.168.131.132";
    const char* unicast_ip_2 = "192.168.131.145";
    dal_locator_t m_locator_1;
    dal_locator_t m_locator_2;
    dal_locator_t u_locator_1;
    dal_locator_t u_locator_2;
    memset(&m_locator_1, 0, sizeof(dal_locator_t));
    memset(&m_locator_2, 0, sizeof(dal_locator_t));
    memset(&u_locator_1, 0, sizeof(dal_locator_t));
    memset(&u_locator_1, 0, sizeof(dal_locator_t));
    m_locator_1.kind = DAL_LOCATOR_KIND_UDPv4;
    m_locator_2.kind = DAL_LOCATOR_KIND_UDPv4;
    u_locator_1.kind = DAL_LOCATOR_KIND_UDPv4;
    u_locator_2.kind = DAL_LOCATOR_KIND_UDPv4;
    memcpy(&m_locator_1.address, multicast_ip_1, strlen(multicast_ip_1));
    memcpy(&m_locator_2.address, multicast_ip_2, strlen(multicast_ip_2));
    memcpy(&u_locator_1.address, unicast_ip_1, strlen(unicast_ip_1));
    memcpy(&u_locator_2.address, unicast_ip_2, strlen(unicast_ip_2));

    INIT_SEQUENCE(octet, &d_qos.user_data.value);
    PUSH_BACK_SEQUENCE(octet, &d_qos.user_data.value, 11);
    PUSH_BACK_SEQUENCE(octet, &d_qos.user_data.value, 22);

    d_qos.entity_factory.autoenable_created_entities = DAL_TRUE;
    d_qos.participant_name = "DefinedParticipant";
    d_qos.localhost_only = DAL_TRUE;

    INIT_SEQUENCE_WITH_CAPACITY(dal_locator_t, &d_qos.multicast_locator_seq, 5);
    INIT_SEQUENCE_WITH_CAPACITY(dal_locator_t, &d_qos.unicast_locator_seq, 5);

    PUSH_BACK_SEQUENCE(dal_locator_t, &d_qos.multicast_locator_seq, m_locator_1);
    PUSH_BACK_SEQUENCE(dal_locator_t, &d_qos.multicast_locator_seq, m_locator_2);
    PUSH_BACK_SEQUENCE(dal_locator_t, &d_qos.unicast_locator_seq, u_locator_1);
    PUSH_BACK_SEQUENCE(dal_locator_t, &d_qos.unicast_locator_seq, u_locator_2);

    ret = QosConverter::GetInstance()->ConvertParticipantQosFromDalToFastdds(&d_qos, &f_qos);

    EXPECT_EQ(ret, DAL_RETCODE_OK);
    EXPECT_EQ(f_qos.user_data().data_vec().at(0), 11);
    EXPECT_EQ(f_qos.user_data().data_vec().at(1), 22);
    EXPECT_EQ(f_qos.entity_factory().autoenable_created_entities, true);

    EXPECT_EQ(f_qos.name(), "DefinedParticipant");

    EXPECT_EQ(f_qos.transport().use_builtin_transports, false);
#ifdef __QNXNTO__
    EXPECT_EQ(f_qos.transport().user_transports.size(), 2);
#else
    EXPECT_EQ(f_qos.transport().user_transports.size(), 3);
#endif
    EXPECT_EQ(f_qos.wire_protocol().builtin.metatrafficMulticastLocatorList.size(), 2);
    EXPECT_EQ(f_qos.wire_protocol().default_unicast_locator_list.size(), 2);
    EXPECT_EQ(f_qos.wire_protocol().builtin.metatrafficUnicastLocatorList.size(), 2);
}

TEST(participant_qos_convert_no_locator, test_convert_qos)
{
    dal_ret_t ret;
    dal_domain_participant_qos_t d_qos = { };
    DomainParticipantQos f_qos;

    INIT_SEQUENCE(octet, &d_qos.user_data.value);
    PUSH_BACK_SEQUENCE(octet, &d_qos.user_data.value, 11);
    PUSH_BACK_SEQUENCE(octet, &d_qos.user_data.value, 22);

    d_qos.localhost_only = DAL_FALSE;
    INIT_SEQUENCE_WITH_CAPACITY(dal_locator_t, &d_qos.multicast_locator_seq, 5);
    INIT_SEQUENCE_WITH_CAPACITY(dal_locator_t, &d_qos.unicast_locator_seq, 5);
    CLEAR_SEQUENCE(dal_locator_t, &d_qos.multicast_locator_seq);
    CLEAR_SEQUENCE(dal_locator_t, &d_qos.unicast_locator_seq);

    ret = QosConverter::GetInstance()->ConvertParticipantQosFromDalToFastdds(&d_qos, &f_qos);

    EXPECT_EQ(ret, DAL_RETCODE_OK);
    EXPECT_EQ(f_qos.user_data().data_vec().at(0), 11);
    EXPECT_EQ(f_qos.user_data().data_vec().at(1), 22);

    EXPECT_EQ(f_qos.transport().user_transports.size(), 0);
    EXPECT_EQ(f_qos.wire_protocol().builtin.metatrafficMulticastLocatorList.size(), 1);
    EXPECT_EQ(f_qos.wire_protocol().default_unicast_locator_list.size(), 0);
    EXPECT_EQ(f_qos.wire_protocol().builtin.metatrafficUnicastLocatorList.size(), 0);
}

TEST(publisher_qos_convert, test_convert_qos)
{
    dal_ret_t ret;
    dal_publisher_qos_t d_qos;
    PublisherQos f_qos;

    d_qos.presentation.access_scope = DAL_TOPIC_PRESENTATION_QOS;
    d_qos.presentation.coherent_access = DAL_TRUE;
    d_qos.presentation.ordered_access = DAL_TRUE;
    // TODO: dal_partition_qos_policy_t
    INIT_SEQUENCE(octet, &d_qos.group_data.value);
    PUSH_BACK_SEQUENCE(octet, &d_qos.group_data.value, 11);
    PUSH_BACK_SEQUENCE(octet, &d_qos.group_data.value, 22);
    d_qos.entity_factory.autoenable_created_entities = DAL_TRUE;

    ret = QosConverter::GetInstance()->ConvertPublisherQosFromDalToFastdds(&d_qos, &f_qos);

    EXPECT_EQ(ret, DAL_RETCODE_OK);
    EXPECT_EQ(f_qos.presentation().access_scope, TOPIC_PRESENTATION_QOS);
    EXPECT_EQ(f_qos.presentation().coherent_access, true);
    EXPECT_EQ(f_qos.presentation().ordered_access, true);
    EXPECT_EQ(f_qos.group_data().data_vec().at(0), 11);
    EXPECT_EQ(f_qos.group_data().data_vec().at(1), 22);
    EXPECT_EQ(f_qos.entity_factory().autoenable_created_entities, true);
}

TEST(subscriber_qos_convert, test_convert_qos)
{
    dal_ret_t ret;
    dal_subscriber_qos_t d_qos;
    SubscriberQos f_qos;

    d_qos.presentation.access_scope = DAL_GROUP_PRESENTATION_QOS;
    d_qos.presentation.coherent_access = DAL_TRUE;
    d_qos.presentation.ordered_access = DAL_TRUE;
    // TODO: dal_partition_qos_policy_t
    INIT_SEQUENCE(octet, &d_qos.group_data.value);
    PUSH_BACK_SEQUENCE(octet, &d_qos.group_data.value, 11);
    PUSH_BACK_SEQUENCE(octet, &d_qos.group_data.value, 22);
    d_qos.entity_factory.autoenable_created_entities = DAL_TRUE;

    ret = QosConverter::GetInstance()->ConvertSubscriberQosFromDalToFastdds(&d_qos, &f_qos);

    EXPECT_EQ(ret, DAL_RETCODE_OK);
    EXPECT_EQ(f_qos.presentation().access_scope, GROUP_PRESENTATION_QOS);
    EXPECT_EQ(f_qos.presentation().coherent_access, true);
    EXPECT_EQ(f_qos.presentation().ordered_access, true);
    EXPECT_EQ(f_qos.group_data().data_vec().at(0), 11);
    EXPECT_EQ(f_qos.group_data().data_vec().at(1), 22);
    EXPECT_EQ(f_qos.entity_factory().autoenable_created_entities, true);
}

TEST(topic_qos_convert, test_convert_qos)
{
    dal_ret_t ret;
    dal_topic_qos_t d_qos;
    TopicQos f_qos;

    INIT_SEQUENCE(octet, &d_qos.topic_data.value);
    PUSH_BACK_SEQUENCE(octet, &d_qos.topic_data.value, 11);
    PUSH_BACK_SEQUENCE(octet, &d_qos.topic_data.value, 22);
    d_qos.durability.kind = DAL_TRANSIENT_LOCAL_DURABILITY_QOS;
    d_qos.durability_service.service_cleanup_delay.sec = 111;
    d_qos.durability_service.service_cleanup_delay.nanosec = 222;
    d_qos.durability_service.history_kind = DAL_KEEP_ALL_HISTORY_QOS;
    d_qos.durability_service.history_depth = 111;
    d_qos.durability_service.max_samples = 222;
    d_qos.durability_service.max_instances = 333;
    d_qos.durability_service.max_samples_per_instance = 444;
    d_qos.deadline.period.sec = 555;
    d_qos.deadline.period.nanosec = 666;
    d_qos.latency_budget.duration.sec = 777;
    d_qos.latency_budget.duration.nanosec = 888;
    d_qos.liveliness.kind = DAL_MANUAL_BY_PARTICIPANT_LIVELINESS_QOS;
    d_qos.liveliness.lease_duration.sec = 111;
    d_qos.liveliness.lease_duration.nanosec = 222;
    d_qos.reliability.kind = DAL_RELIABLE_RELIABILITY_QOS;
    d_qos.reliability.max_blocking_time.sec = 333;
    d_qos.reliability.max_blocking_time.nanosec = 444;
    d_qos.destination_order.kind = DAL_BY_SOURCE_TIMESTAMP_DESTINATIONORDER_QOS;
    d_qos.history.kind = DAL_KEEP_ALL_HISTORY_QOS;
    d_qos.history.depth = 555;
    d_qos.resource_limits.max_samples = 666;
    d_qos.resource_limits.max_instances = 777;
    d_qos.resource_limits.max_samples_per_instance = 888;
    d_qos.transport_priority.value = 3;
    d_qos.lifespan.duration.sec = 111;
    d_qos.lifespan.duration.nanosec = 222;
    d_qos.ownership.kind = DAL_EXCLUSIVE_OWNERSHIP_QOS;

    ret = QosConverter::GetInstance()->ConvertTopicQosFromDalToFastdds(&d_qos, &f_qos);

    EXPECT_EQ(ret, DAL_RETCODE_OK);
    EXPECT_EQ(f_qos.topic_data().data_vec().at(0), 11);
    EXPECT_EQ(f_qos.topic_data().data_vec().at(1), 22);
    EXPECT_EQ(f_qos.durability().kind, TRANSIENT_LOCAL_DURABILITY_QOS);
    EXPECT_EQ(f_qos.durability_service().service_cleanup_delay.seconds, 111);
    EXPECT_EQ(f_qos.durability_service().service_cleanup_delay.nanosec, 222);
    EXPECT_EQ(f_qos.durability_service().history_kind, KEEP_ALL_HISTORY_QOS);
    EXPECT_EQ(f_qos.durability_service().history_depth, 111);
    EXPECT_EQ(f_qos.durability_service().max_samples, 222);
    EXPECT_EQ(f_qos.durability_service().max_instances, 333);
    EXPECT_EQ(f_qos.durability_service().max_samples_per_instance, 444);
    EXPECT_EQ(f_qos.deadline().period.seconds, 555);
    EXPECT_EQ(f_qos.deadline().period.nanosec, 666);
    EXPECT_EQ(f_qos.latency_budget().duration.seconds, 777);
    EXPECT_EQ(f_qos.latency_budget().duration.nanosec, 888);
    EXPECT_EQ(f_qos.liveliness().kind, MANUAL_BY_PARTICIPANT_LIVELINESS_QOS);
    EXPECT_EQ(f_qos.liveliness().lease_duration.seconds, 111);
    EXPECT_EQ(f_qos.liveliness().lease_duration.nanosec, 222);
    EXPECT_EQ(f_qos.reliability().kind, RELIABLE_RELIABILITY_QOS);
    EXPECT_EQ(f_qos.reliability().max_blocking_time.seconds, 333);
    EXPECT_EQ(f_qos.reliability().max_blocking_time.nanosec, 444);
    EXPECT_EQ(f_qos.destination_order().kind, BY_SOURCE_TIMESTAMP_DESTINATIONORDER_QOS);
    EXPECT_EQ(f_qos.history().kind, KEEP_LAST_HISTORY_QOS);
    EXPECT_EQ(f_qos.history().depth, 555);
    EXPECT_EQ(f_qos.resource_limits().max_samples, 666);
    EXPECT_EQ(f_qos.resource_limits().max_instances, 777);
    EXPECT_EQ(f_qos.resource_limits().max_samples_per_instance, 888);
    EXPECT_EQ(f_qos.transport_priority().value, 3);
    EXPECT_EQ(f_qos.lifespan().duration.seconds, 111);
    EXPECT_EQ(f_qos.lifespan().duration.nanosec, 222);
    EXPECT_EQ(f_qos.ownership().kind, EXCLUSIVE_OWNERSHIP_QOS);
}

TEST(datawriter_qos_convert, test_convert_qos)
{
    dal_ret_t ret;
    dal_datawriter_qos_t d_qos;
    DataWriterQos f_qos;

    d_qos.durability.kind = DAL_TRANSIENT_LOCAL_DURABILITY_QOS;
    d_qos.durability_service.service_cleanup_delay.sec = 111;
    d_qos.durability_service.service_cleanup_delay.nanosec = 222;
    d_qos.durability_service.history_kind = DAL_KEEP_ALL_HISTORY_QOS;
    d_qos.durability_service.history_depth = 111;
    d_qos.durability_service.max_samples = 222;
    d_qos.durability_service.max_instances = 333;
    d_qos.durability_service.max_samples_per_instance = 444;
    d_qos.deadline.period.sec = 555;
    d_qos.deadline.period.nanosec = 666;
    d_qos.latency_budget.duration.sec = 777;
    d_qos.latency_budget.duration.nanosec = 888;
    d_qos.liveliness.kind = DAL_MANUAL_BY_PARTICIPANT_LIVELINESS_QOS;
    d_qos.liveliness.lease_duration.sec = 111;
    d_qos.liveliness.lease_duration.nanosec = 222;
    d_qos.reliability.kind = DAL_RELIABLE_RELIABILITY_QOS;
    d_qos.reliability.max_blocking_time.sec = 333;
    d_qos.reliability.max_blocking_time.nanosec = 444;
    d_qos.destination_order.kind = DAL_BY_SOURCE_TIMESTAMP_DESTINATIONORDER_QOS;
    d_qos.history.kind = DAL_KEEP_ALL_HISTORY_QOS;
    d_qos.history.depth = 555;
    d_qos.resource_limits.max_samples = 666;
    d_qos.resource_limits.max_instances = 777;
    d_qos.resource_limits.max_samples_per_instance = 888;
    d_qos.transport_priority.value = 3;
    d_qos.lifespan.duration.sec = 111;
    d_qos.lifespan.duration.nanosec = 222;
    INIT_SEQUENCE(octet, &d_qos.user_data.value);
    PUSH_BACK_SEQUENCE(octet, &d_qos.user_data.value, 11);
    PUSH_BACK_SEQUENCE(octet, &d_qos.user_data.value, 22);
    d_qos.ownership.kind = DAL_EXCLUSIVE_OWNERSHIP_QOS;
    d_qos.ownership_strength.value = 4;
    d_qos.writer_data_lifecycle.autodispose_unregistered_instances = 5;

    ret = QosConverter::GetInstance()->ConvertDataWriterQosFromDalToFastdds(&d_qos, &f_qos);

    EXPECT_EQ(ret, DAL_RETCODE_OK);
    EXPECT_EQ(f_qos.durability().kind, TRANSIENT_LOCAL_DURABILITY_QOS);
    EXPECT_EQ(f_qos.durability_service().service_cleanup_delay.seconds, 111);
    EXPECT_EQ(f_qos.durability_service().service_cleanup_delay.nanosec, 222);
    EXPECT_EQ(f_qos.durability_service().history_kind, KEEP_ALL_HISTORY_QOS);
    EXPECT_EQ(f_qos.durability_service().history_depth, 111);
    EXPECT_EQ(f_qos.durability_service().max_samples, 222);
    EXPECT_EQ(f_qos.durability_service().max_instances, 333);
    EXPECT_EQ(f_qos.durability_service().max_samples_per_instance, 444);
    EXPECT_EQ(f_qos.deadline().period.seconds, 555);
    EXPECT_EQ(f_qos.deadline().period.nanosec, 666);
    EXPECT_EQ(f_qos.latency_budget().duration.seconds, 777);
    EXPECT_EQ(f_qos.latency_budget().duration.nanosec, 888);
    EXPECT_EQ(f_qos.liveliness().kind, MANUAL_BY_PARTICIPANT_LIVELINESS_QOS);
    EXPECT_EQ(f_qos.liveliness().lease_duration.seconds, 111);
    EXPECT_EQ(f_qos.liveliness().lease_duration.nanosec, 222);
    EXPECT_EQ(f_qos.reliability().kind, RELIABLE_RELIABILITY_QOS);
    EXPECT_EQ(f_qos.reliability().max_blocking_time.seconds, 333);
    EXPECT_EQ(f_qos.reliability().max_blocking_time.nanosec, 444);
    EXPECT_EQ(f_qos.destination_order().kind, BY_SOURCE_TIMESTAMP_DESTINATIONORDER_QOS);
    EXPECT_EQ(f_qos.history().kind, KEEP_LAST_HISTORY_QOS);
    EXPECT_EQ(f_qos.history().depth, 555);
    EXPECT_EQ(f_qos.resource_limits().max_samples, 666);
    EXPECT_EQ(f_qos.resource_limits().max_instances, 777);
    EXPECT_EQ(f_qos.resource_limits().max_samples_per_instance, 888);
    EXPECT_EQ(f_qos.transport_priority().value, 3);
    EXPECT_EQ(f_qos.lifespan().duration.seconds, 111);
    EXPECT_EQ(f_qos.lifespan().duration.nanosec, 222);
    EXPECT_EQ(f_qos.user_data().data_vec().at(0), 11);
    EXPECT_EQ(f_qos.user_data().data_vec().at(1), 22);
    EXPECT_EQ(f_qos.ownership().kind, EXCLUSIVE_OWNERSHIP_QOS);
    EXPECT_EQ(f_qos.ownership_strength().value, 4);
    EXPECT_EQ(f_qos.writer_data_lifecycle().autodispose_unregistered_instances, true);
}

TEST(datareader_qos_convert, test_convert_qos)
{
    dal_ret_t ret;
    dal_datareader_qos_t d_qos;
    DataReaderQos f_qos;

    d_qos.durability.kind = DAL_TRANSIENT_LOCAL_DURABILITY_QOS;
    d_qos.deadline.period.sec = 555;
    d_qos.deadline.period.nanosec = 666;
    d_qos.latency_budget.duration.sec = 777;
    d_qos.latency_budget.duration.nanosec = 888;
    d_qos.liveliness.kind = DAL_MANUAL_BY_PARTICIPANT_LIVELINESS_QOS;
    d_qos.liveliness.lease_duration.sec = 111;
    d_qos.liveliness.lease_duration.nanosec = 222;
    d_qos.reliability.kind = DAL_RELIABLE_RELIABILITY_QOS;
    d_qos.reliability.max_blocking_time.sec = 333;
    d_qos.reliability.max_blocking_time.nanosec = 444;
    d_qos.destination_order.kind = DAL_BY_SOURCE_TIMESTAMP_DESTINATIONORDER_QOS;
    d_qos.history.kind = DAL_KEEP_ALL_HISTORY_QOS;
    d_qos.history.depth = 555;
    d_qos.resource_limits.max_samples = 666;
    d_qos.resource_limits.max_instances = 777;
    d_qos.resource_limits.max_samples_per_instance = 888;
    INIT_SEQUENCE(octet, &d_qos.user_data.value);
    PUSH_BACK_SEQUENCE(octet, &d_qos.user_data.value, 11);
    PUSH_BACK_SEQUENCE(octet, &d_qos.user_data.value, 22);
    d_qos.ownership.kind = DAL_EXCLUSIVE_OWNERSHIP_QOS;
    d_qos.time_based_filter.minimum_separation.sec = 11;
    d_qos.time_based_filter.minimum_separation.nanosec = 22;
    d_qos.reader_data_lifecycle.autopurge_nowriter_samples_delay.sec = 33;
    d_qos.reader_data_lifecycle.autopurge_nowriter_samples_delay.nanosec = 44;
    d_qos.reader_data_lifecycle.autopurge_disposed_samples_delay.sec = 55;
    d_qos.reader_data_lifecycle.autopurge_disposed_samples_delay.nanosec = 66;

    ret = QosConverter::GetInstance()->ConvertDataReaderQosFromDalToFastdds(&d_qos, &f_qos);

    EXPECT_EQ(ret, DAL_RETCODE_OK);
    EXPECT_EQ(f_qos.durability().kind, TRANSIENT_LOCAL_DURABILITY_QOS);
    EXPECT_EQ(f_qos.deadline().period.seconds, 555);
    EXPECT_EQ(f_qos.deadline().period.nanosec, 666);
    EXPECT_EQ(f_qos.latency_budget().duration.seconds, 777);
    EXPECT_EQ(f_qos.latency_budget().duration.nanosec, 888);
    EXPECT_EQ(f_qos.liveliness().kind, MANUAL_BY_PARTICIPANT_LIVELINESS_QOS);
    EXPECT_EQ(f_qos.liveliness().lease_duration.seconds, 111);
    EXPECT_EQ(f_qos.liveliness().lease_duration.nanosec, 222);
    EXPECT_EQ(f_qos.reliability().kind, RELIABLE_RELIABILITY_QOS);
    EXPECT_EQ(f_qos.reliability().max_blocking_time.seconds, 333);
    EXPECT_EQ(f_qos.reliability().max_blocking_time.nanosec, 444);
    EXPECT_EQ(f_qos.destination_order().kind, BY_SOURCE_TIMESTAMP_DESTINATIONORDER_QOS);
    EXPECT_EQ(f_qos.history().kind, KEEP_LAST_HISTORY_QOS);
    EXPECT_EQ(f_qos.history().depth, 555);
    EXPECT_EQ(f_qos.resource_limits().max_samples, 666);
    EXPECT_EQ(f_qos.resource_limits().max_instances, 777);
    EXPECT_EQ(f_qos.resource_limits().max_samples_per_instance, 888);
    EXPECT_EQ(f_qos.user_data().data_vec().at(0), 11);
    EXPECT_EQ(f_qos.user_data().data_vec().at(1), 22);
    EXPECT_EQ(f_qos.ownership().kind, EXCLUSIVE_OWNERSHIP_QOS);
    EXPECT_EQ(f_qos.time_based_filter().minimum_separation.seconds, 11);
    EXPECT_EQ(f_qos.time_based_filter().minimum_separation.nanosec, 22);
    EXPECT_EQ(f_qos.reader_data_lifecycle().autopurge_no_writer_samples_delay.seconds, 33);
    EXPECT_EQ(f_qos.reader_data_lifecycle().autopurge_no_writer_samples_delay.nanosec, 44);
    EXPECT_EQ(f_qos.reader_data_lifecycle().autopurge_disposed_samples_delay.seconds, 55);
    EXPECT_EQ(f_qos.reader_data_lifecycle().autopurge_disposed_samples_delay.nanosec, 66);
}
